# -*- coding: utf-8 -*-

import os
from MsgProcess import MsgProcess, MsgType

class XMLY(MsgProcess):
    def Text(self, message=None):  

        data = message["Data"][4:]

        if "继续播放" in data:
            #print("继续播放")
            datas = {  "type":"exejs","data":"xmly_Resume()"  }
            self.send( MsgType=MsgType.Text, Receiver="Screen", Data= datas )
            return 1

        if "下个节目" in data:
            #print("下个节目")
            datas = {  "type":"exejs","data":"xmly_prev_program()"   }
            self.send( MsgType=MsgType.Text, Receiver="Screen", Data= datas )
            return 1

        if "上个节目" in data:
            #print("上个节目")
            datas = {  "type":"exejs","data":"xmly_next_program()"  }
            self.send( MsgType=MsgType.Text, Receiver="Screen", Data= datas )
            return 1


        if "下1个" in data:
            #print("下1个")
            datas = {  "type":"exejs","data":"xmly_next()"   }
            self.send( MsgType=MsgType.Text, Receiver="Screen", Data= datas )
            return 1

        if "上1个" in data:
            #print("上1个")
            datas = {  "type":"exejs","data":"xmly_prev()"  }
            self.send( MsgType=MsgType.Text, Receiver="Screen", Data= datas )
            return 1

        if  len(data)>=1:
            #print(data)
            datas = {  "type":"exejs","data":"xmly_main('{0}')".format( data )   }
            self.send( MsgType=MsgType.Text, Receiver="Screen", Data= datas )

    #唤醒暂停
    def Awake(self,message=None):
        datas = {  "type":"exejs","data":"xmly_pause()"  }
        self.send( MsgType=MsgType.Text, Receiver="Screen", Data= datas )

